Sync from Nautilus commit 480b1daf8814063f348d0f75082353a2f6a3eab3
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 21 Jan 2013 21:38:23 +0000 (16:38 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 21 Jan 2013 21:38:23 +0000 (16:38 -0500)
cancel the hostnamed proxy creation on dispose

gtk/gtkplacessidebar.c

index f944fb7e163181a320c95c530877ca56aa5d524c..40ab3e0cbc861f7ab0499ca948eae9d4f46e09f0 100644 (file)
@@ -152,6 +152,7 @@ struct _GtkPlacesSidebar {
        GSList *shortcuts;
 
        GDBusProxy *hostnamed_proxy;
+       GCancellable *hostnamed_cancellable;
        char *hostname;
 
        GtkPlacesOpenFlags open_flags;
@@ -3226,6 +3227,8 @@ hostname_proxy_new_cb (GObject      *source_object,
        GError *error = NULL;
 
        sidebar->hostnamed_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+       g_clear_object (&sidebar->hostnamed_cancellable);
+
        if (error != NULL) {
                g_debug ("Failed to create D-Bus proxy: %s", error->message);
                g_error_free (error);
@@ -3504,13 +3507,14 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
        tree_view_set_activate_on_single_click (sidebar->tree_view);
 
        sidebar->hostname = g_strdup (_("Computer"));
+       sidebar->hostnamed_cancellable = g_cancellable_new ();
        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
                                  G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
                                  NULL,
                                  "org.freedesktop.hostname1",
                                  "/org/freedesktop/hostname1",
                                  "org.freedesktop.hostname1",
-                                 NULL,
+                                 sidebar->hostnamed_cancellable,
                                  hostname_proxy_new_cb,
                                  sidebar);
 }
@@ -3570,6 +3574,11 @@ gtk_places_sidebar_dispose (GObject *object)
                g_clear_object (&sidebar->volume_monitor);
        }
 
+       if (sidebar->hostnamed_cancellable != NULL) {
+               g_cancellable_cancel (sidebar->hostnamed_cancellable);
+               g_clear_object (&sidebar->hostnamed_cancellable);
+       }
+
        g_clear_object (&sidebar->hostnamed_proxy);
        g_free (sidebar->hostname);
        sidebar->hostname = NULL;